package main

import (
	"fmt"
	"net"
	"net/rpc"
)

type AddRequest struct {
	Left  int
	Right int
}

type AddResponse struct {
	Result int
}

type Calc struct {
}

func (c *Calc) Add(req AddRequest, resp *AddResponse) error {
	fmt.Println("calc.add")
	resp.Result = req.Left + req.Right
	return nil
}

func main() {
	//req := AddRequest{1, 2}
	//resp := AddResponse{}
	//calc := Calc{}
	//calc.Add(req, &resp)
	//fmt.Println(resp.result)

	rpc.Register(&Calc{})
	listener, _ := net.Listen("tcp", "0.0.0.0:8888")
	rpc.Accept(listener)
	defer listener.Close()

}
